BASEDIR = ..

INC_DIR = $(BASEDIR)/include ./inc
OBJ_DIR = $(BASEDIR)/obj
BIN_DIR = $(BASEDIR)/bin

EXECUTABLE = $(BIN_DIR)/egos

SRC = egos.c ring_buffer.c stubs.c mutex.c task.c

_OBJ = $(addsuffix .o, $(basename $(SRC)))
OBJ = $(patsubst %,$(OBJ_DIR)/%,$(_OBJ))


# set up compiler and options
CC = gcc
CFLAGS = -g -Wall -I$(INC_DIR)

$(EXECUTABLE): $(OBJ)
	$(CC) $(LFLAGS) $(OBJ) -o $@

$(OBJ_DIR)/%.o: %.c
	$(CC) $(CFLAGS) -c $< -o $@


.PHONY: print_vars
print_vars:
	echo $(SRC)
	echo $(OBJ)

.PHONY: config
config:
	echo $(SRC)
	echo $(OBJ)

# the target clean does not give an output file named clean, so it is a phony target
.PHONY : clean
clean:
	rm -f $(OBJ)
	rm -f $(EXECUTABLE)
